local baizhan = fk.CreateSkill {
  name = "lingling__baizhan",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["lingling__baizhan"] = "百战",
  [":lingling__baizhan"] = "锁定技，你不同攻击范围下使用的【杀】次数限制单独计算。",

  ["@lingling__baizhan"] = "攻击范围",
}

baizhan:addEffect(fk.PreCardUse, {
  can_refresh = function (self, event, target, player, data)
    return target == player and player:hasSkill(baizhan.name) and
      player.phase == Player.Play and data.card.trueName == "slash" and not data.extraUse
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:addTableMark(player, "lingling__baizhan-phase", player:getAttackRange())
  end,
})

baizhan:addEffect("targetmod", {
  bypass_times = function (self, player, skill, scope, card, to)
    return player:hasSkill(baizhan.name) and card and card.trueName == "slash" and to and
      not table.contains(player:getTableMark("lingling__baizhan-phase"), player:getAttackRange())
  end,
})

baizhan:addEffect("visibility", {
  role_visible = function (self, player, target)
    if player:getMark("@lingling__baizhan") ~= player:getAttackRange() and player:hasSkill(baizhan.name, true) then
      player:setMark("@lingling__baizhan", player:getAttackRange())
    end
  end,
})

return baizhan
